print("")


class Student:
    name = ""

    def say_name(self):
        print("我叫:", self.name)

    def sya(self, msg):
        print(f"{self.name}:", msg)


stu_1 = Student()

stu_1.name = "小明"

stu_1.say_name()
stu_1.sya("天气好热")


# 2.构造方法
class Person:

    def __init__(self, name, age):
        self.name = name
        self.age = age


p1 = Person('兔子', 20)
print("p1 = ", p1)
print(p1.name)


# 3.内置方法__str__
class Person2:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __str__(self):
        # return "{name:{" + self.name + "},age:{" + self.age + "}}"
        return "{name:" + self.name + ", age:" + str(self.age) + "}"


p2 = Person2('兔子2', 40)
print("p2 = ", p2)
